<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head profile="http://purl.org/NET/erdf/profile">


 <title>PHP: MySQL - Manual</title>
 <style type="text/css" media="all">
  @import url("/styles/site.css");
  @import url("/styles/mirror.css");
 </style>
 <!--[if IE]><![if gte IE 6]><![endif]-->
  <style type="text/css" media="print">
   @import url("/styles/print.css");
  </style>
 <!--[if IE]><![endif]><![endif]-->
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <link rel="shortcut icon" href="http://au2.php.net/favicon.ico">
 <link rel="contents" href="http://au2.php.net/manual/en/index.php">
 <link rel="index" href="http://au2.php.net/manual/en/refs.database.vendors.php">
 <link rel="prev" href="http://au2.php.net/manual/en/function.mssql-select-db.php">
 <link rel="next" href="http://au2.php.net/manual/en/intro.mysql.php">
 <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/">
 <link rel="schema.rdfs" href="http://www.w3.org/2000/01/rdf-schema#">
 <script type="text/javascript" src="mysql_files/userprefs.js"></script>
 <!-- base href="http://au2.php.net/manual/en/book.mysql.php" -->
</head><body>

<div id="headnav">
 <a href="http://au2.php.net/" rel="home"><img src="mysql_files/php.gif" alt="PHP" width="120" height="67"></a>
 <div id="headmenu">
  <a href="http://au2.php.net/downloads.php">downloads</a> |
  <a href="http://au2.php.net/docs.php">documentation</a> |
  <a href="http://au2.php.net/FAQ.php">faq</a> |
  <a href="http://au2.php.net/support.php">getting help</a> |
  <a href="http://au2.php.net/mailing-lists.php">mailing lists</a> |
  <a href="http://au2.php.net/license">licenses</a> |
  <a href="http://wiki.php.net/">wiki</a> |
  <a href="http://bugs.php.net/">reporting bugs</a> |
  <a href="http://au2.php.net/sites.php">php.net sites</a> |
  <a href="http://au2.php.net/links.php">links</a> |
  <a href="http://au2.php.net/conferences/">conferences</a> |
  <a href="http://au2.php.net/my.php">my php.net</a>
 </div>
</div>

<div id="headsearch">
 <form method="post" action="/search.php" id="topsearch">
  <p>
   <span title="Keyboard shortcut: Alt+S (Win), Ctrl+S (Apple)">
    <span class="shortkey">s</span>earch for
   </span>
   <input name="pattern" value="" size="30" accesskey="s" type="text">
   <span>in the</span>
   <select name="show">
    <option value="quickref" selected="selected">function list</option>
    <option value="all">all php.net sites</option>
    <option value="local">this mirror only</option>
    <option value="manual">online documentation</option>
    <option value="bugdb">bug database</option>
    <option value="news_archive">Site News Archive</option>
    <option value="changelogs">All Changelogs</option>
    <option value="pear">just pear.php.net</option>
    <option value="pecl">just pecl.php.net</option>
    <option value="talks">just talks.php.net</option>
    <option value="maillist">general mailing list</option>
    <option value="devlist">developer mailing list</option>
    <option value="phpdoc">documentation mailing list</option>
   </select>
   <input src="mysql_files/small_submit_white.gif" class="submit" alt="search" type="image">
  </p>
 </form>
</div>

<div id="layout_2">
 <div id="leftbar">
<!--UdmComment-->
<ul class="toc">
 <li class="header home"><a href="http://au2.php.net/manual/en/index.php">PHP Manual</a></li>
 <li class="header up"><a href="http://au2.php.net/manual/en/funcref.php">Function Reference</a></li>
 <li class="header up"><a href="http://au2.php.net/manual/en/refs.database.php">Database Extensions</a></li>
 <li class="header up"><a href="http://au2.php.net/manual/en/refs.database.vendors.php">Vendor Specific Database Extensions</a></li>
 <li><a href="http://au2.php.net/manual/en/book.dbase.php">dBase</a></li>
 <li><a href="http://au2.php.net/manual/en/book.dbplus.php">DB++</a></li>
 <li><a href="http://au2.php.net/manual/en/book.fbsql.php">FrontBase</a></li>
 <li><a href="http://au2.php.net/manual/en/book.filepro.php">filePro</a></li>
 <li><a href="http://au2.php.net/manual/en/book.ibase.php">Firebird/InterBase</a></li>
 <li><a href="http://au2.php.net/manual/en/book.ifx.php">Informix</a></li>
 <li><a href="http://au2.php.net/manual/en/book.ibm-db2.php">IBM DB2</a></li>
 <li><a href="http://au2.php.net/manual/en/book.ingres.php">Ingres</a></li>
 <li><a href="http://au2.php.net/manual/en/book.maxdb.php">MaxDB</a></li>
 <li><a href="http://au2.php.net/manual/en/book.mongo.php">Mongo</a></li>
 <li><a href="http://au2.php.net/manual/en/book.msql.php">mSQL</a></li>
 <li><a href="http://au2.php.net/manual/en/book.mssql.php">Mssql</a></li>
 <li class="active"><a href="http://au2.php.net/manual/en/book.mysql.php">MySQL</a></li>
 <li><a href="http://au2.php.net/manual/en/book.mysqli.php">Mysqli</a></li>
 <li><a href="http://au2.php.net/manual/en/book.oci8.php">OCI8</a></li>
 <li><a href="http://au2.php.net/manual/en/book.ovrimos.php">Ovrimos SQL</a></li>
 <li><a href="http://au2.php.net/manual/en/book.paradox.php">Paradox</a></li>
 <li><a href="http://au2.php.net/manual/en/book.pgsql.php">PostgreSQL</a></li>
 <li><a href="http://au2.php.net/manual/en/book.sqlite.php">SQLite</a></li>
 <li><a href="http://au2.php.net/manual/en/book.sqlite3.php">SQLite3</a></li>
 <li><a href="http://au2.php.net/manual/en/book.sybase.php">Sybase</a></li>
</ul><!--/UdmComment-->

 </div>
 <div id="content" class="manual/en">
<!--UdmComment-->
<div class="manualnavbar manualnavbar_top">
 <span class="next">
  <a href="http://au2.php.net/manual/en/intro.mysql.php">Introduction<img src="mysql_files/caret-r.gif" alt="&gt;" width="11" height="7"></a>
 </span>
 <span class="prev">
  <a href="http://au2.php.net/manual/en/function.mssql-select-db.php"><img src="mysql_files/caret-l.gif" alt="&lt;" width="11" height="7">mssql_select_db</a>
 </span>
 <hr>
 <span class="lastupdated">Last updated: Fri, 20 Mar 2009</span>
 <div class="langchooser">
  <form action="/manual/change.php" method="get">
   <p>view this page in </p><fieldset><select name="page">
    <option value="bg/book.mysql.php">Bulgarian</option>
    <option value="pt_BR/book.mysql.php">Brazilian Portuguese</option>
    <option value="fr/book.mysql.php">French</option>
    <option value="de/book.mysql.php">German</option>
    <option value="ja/book.mysql.php">Japanese</option>
    <option value="kr/book.mysql.php">Korean</option>
    <option value="pl/book.mysql.php">Polish</option>
    <option value="ro/book.mysql.php">Romanian</option>
    <option value="ru/book.mysql.php">Russian</option>
    <option value="es/book.mysql.php">Spanish</option>
    <option value="tr/book.mysql.php">Turkish</option>
    <option value="help-translate.php">Other</option>
   </select>
   <input src="mysql_files/small_submit.gif" id="changeLangImage" alt="Change language" type="image">
  </fieldset></form>
 </div>
</div>
<!--/UdmComment-->

<div>
 <h1 class="title">MySQL</h1>
 
 
 
 
 
 







 





 







 


 





<ul class="chunklist chunklist_book"><li><a href="http://au2.php.net/manual/en/intro.mysql.php">Introduction</a></li><li><a href="http://au2.php.net/manual/en/mysql.setup.php">Installing/Configuring</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="http://au2.php.net/manual/en/mysql.requirements.php">Requirements</a></li><li><a href="http://au2.php.net/manual/en/mysql.installation.php">Installation</a></li><li><a href="http://au2.php.net/manual/en/mysql.configuration.php">Runtime Configuration</a></li><li><a href="http://au2.php.net/manual/en/mysql.resources.php">Resource Types</a></li></ul></li><li><a href="http://au2.php.net/manual/en/mysql.constants.php">Predefined Constants</a></li><li><a href="http://au2.php.net/manual/en/mysql.examples.php">Examples</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="http://au2.php.net/manual/en/mysql.examples-basic.php">MySQL extension overview example</a></li></ul></li><li><a href="http://au2.php.net/manual/en/ref.mysql.php">MySQL Functions</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="http://au2.php.net/manual/en/function.mysql-affected-rows.php">mysql_affected_rows</a> — Get number of affected rows in previous MySQL operation</li><li><a href="http://au2.php.net/manual/en/function.mysql-change-user.php">mysql_change_user</a> — Change logged in user of the active connection</li><li><a href="http://au2.php.net/manual/en/function.mysql-client-encoding.php">mysql_client_encoding</a> — Returns the name of the character set</li><li><a href="http://au2.php.net/manual/en/function.mysql-close.php">mysql_close</a> — Close MySQL connection</li><li><a href="http://au2.php.net/manual/en/function.mysql-connect.php">mysql_connect</a> — Open a connection to a MySQL Server</li><li><a href="http://au2.php.net/manual/en/function.mysql-create-db.php">mysql_create_db</a> — Create a MySQL database</li><li><a href="http://au2.php.net/manual/en/function.mysql-data-seek.php">mysql_data_seek</a> — Move internal result pointer</li><li><a href="http://au2.php.net/manual/en/function.mysql-db-name.php">mysql_db_name</a> — Get result data</li><li><a href="http://au2.php.net/manual/en/function.mysql-db-query.php">mysql_db_query</a> — Send a MySQL query</li><li><a href="http://au2.php.net/manual/en/function.mysql-drop-db.php">mysql_drop_db</a> — Drop (delete) a MySQL database</li><li><a href="http://au2.php.net/manual/en/function.mysql-errno.php">mysql_errno</a> — Returns the numerical value of the error message from previous MySQL operation</li><li><a href="http://au2.php.net/manual/en/function.mysql-error.php">mysql_error</a> — Returns the text of the error message from previous MySQL operation</li><li><a href="http://au2.php.net/manual/en/function.mysql-escape-string.php">mysql_escape_string</a> — Escapes a string for use in a mysql_query</li><li><a href="http://au2.php.net/manual/en/function.mysql-fetch-array.php">mysql_fetch_array</a> — Fetch a result row as an associative array, a numeric array, or both</li><li><a href="http://au2.php.net/manual/en/function.mysql-fetch-assoc.php">mysql_fetch_assoc</a> — Fetch a result row as an associative array</li><li><a href="http://au2.php.net/manual/en/function.mysql-fetch-field.php">mysql_fetch_field</a> — Get column information from a result and return as an object</li><li><a href="http://au2.php.net/manual/en/function.mysql-fetch-lengths.php">mysql_fetch_lengths</a> — Get the length of each output in a result</li><li><a href="http://au2.php.net/manual/en/function.mysql-fetch-object.php">mysql_fetch_object</a> — Fetch a result row as an object</li><li><a href="http://au2.php.net/manual/en/function.mysql-fetch-row.php">mysql_fetch_row</a> — Get a result row as an enumerated array</li><li><a href="http://au2.php.net/manual/en/function.mysql-field-flags.php">mysql_field_flags</a> — Get the flags associated with the specified field in a result</li><li><a href="http://au2.php.net/manual/en/function.mysql-field-len.php">mysql_field_len</a> — Returns the length of the specified field</li><li><a href="http://au2.php.net/manual/en/function.mysql-field-name.php">mysql_field_name</a> — Get the name of the specified field in a result</li><li><a href="http://au2.php.net/manual/en/function.mysql-field-seek.php">mysql_field_seek</a> — Set result pointer to a specified field offset</li><li><a href="http://au2.php.net/manual/en/function.mysql-field-table.php">mysql_field_table</a> — Get name of the table the specified field is in</li><li><a href="http://au2.php.net/manual/en/function.mysql-field-type.php">mysql_field_type</a> — Get the type of the specified field in a result</li><li><a href="http://au2.php.net/manual/en/function.mysql-free-result.php">mysql_free_result</a> — Free result memory</li><li><a href="http://au2.php.net/manual/en/function.mysql-get-client-info.php">mysql_get_client_info</a> — Get MySQL client info</li><li><a href="http://au2.php.net/manual/en/function.mysql-get-host-info.php">mysql_get_host_info</a> — Get MySQL host info</li><li><a href="http://au2.php.net/manual/en/function.mysql-get-proto-info.php">mysql_get_proto_info</a> — Get MySQL protocol info</li><li><a href="http://au2.php.net/manual/en/function.mysql-get-server-info.php">mysql_get_server_info</a> — Get MySQL server info</li><li><a href="http://au2.php.net/manual/en/function.mysql-info.php">mysql_info</a> — Get information about the most recent query</li><li><a href="http://au2.php.net/manual/en/function.mysql-insert-id.php">mysql_insert_id</a> — Get the ID generated from the previous INSERT operation</li><li><a href="http://au2.php.net/manual/en/function.mysql-list-dbs.php">mysql_list_dbs</a> — List databases available on a MySQL server</li><li><a href="http://au2.php.net/manual/en/function.mysql-list-fields.php">mysql_list_fields</a> — List MySQL table fields</li><li><a href="http://au2.php.net/manual/en/function.mysql-list-processes.php">mysql_list_processes</a> — List MySQL processes</li><li><a href="http://au2.php.net/manual/en/function.mysql-list-tables.php">mysql_list_tables</a> — List tables in a MySQL database</li><li><a href="http://au2.php.net/manual/en/function.mysql-num-fields.php">mysql_num_fields</a> — Get number of fields in result</li><li><a href="http://au2.php.net/manual/en/function.mysql-num-rows.php">mysql_num_rows</a> — Get number of rows in result</li><li><a href="http://au2.php.net/manual/en/function.mysql-pconnect.php">mysql_pconnect</a> — Open a persistent connection to a MySQL server</li><li><a href="http://au2.php.net/manual/en/function.mysql-ping.php">mysql_ping</a> — Ping a server connection or reconnect if there is no connection</li><li><a href="http://au2.php.net/manual/en/function.mysql-query.php">mysql_query</a> — Send a MySQL query</li><li><a href="http://au2.php.net/manual/en/function.mysql-real-escape-string.php">mysql_real_escape_string</a> — Escapes special characters in a string for use in a SQL statement</li><li><a href="http://au2.php.net/manual/en/function.mysql-result.php">mysql_result</a> — Get result data</li><li><a href="http://au2.php.net/manual/en/function.mysql-select-db.php">mysql_select_db</a> — Select a MySQL database</li><li><a href="http://au2.php.net/manual/en/function.mysql-set-charset.php">mysql_set_charset</a> — Sets the client character set</li><li><a href="http://au2.php.net/manual/en/function.mysql-stat.php">mysql_stat</a> — Get current system status</li><li><a href="http://au2.php.net/manual/en/function.mysql-tablename.php">mysql_tablename</a> — Get table name of field</li><li><a href="http://au2.php.net/manual/en/function.mysql-thread-id.php">mysql_thread_id</a> — Return the current thread ID</li><li><a href="http://au2.php.net/manual/en/function.mysql-unbuffered-query.php">mysql_unbuffered_query</a> — Send an SQL query to MySQL, without fetching and buffering the result rows</li></ul></li></ul></div><br><br>
<div id="usernotes">
 <div class="head">
  <span class="action"><a href="http://au2.php.net/manual/add-note.php?sect=book.mysql&amp;redirect=http://au2.php.net/manual/en/book.mysql.php"><img src="mysql_files/notes-add.gif" alt="add a note" class="middle" width="13" height="13"></a> <small><a href="http://au2.php.net/manual/add-note.php?sect=book.mysql&amp;redirect=http://au2.php.net/manual/en/book.mysql.php">add a note</a></small></span>
  <small>User Contributed Notes</small><br>
  <strong>MySQL</strong>
 </div>
 <div class="note">There are no user contributed notes for this page.</div></div><br><!--UdmComment-->
<div class="manualnavbar manualnavbar_bottom">
 <span class="next">
  <a href="http://au2.php.net/manual/en/intro.mysql.php">Introduction<img src="mysql_files/caret-r.gif" alt="&gt;" width="11" height="7"></a>
 </span>
 <span class="prev">
  <a href="http://au2.php.net/manual/en/function.mssql-select-db.php"><img src="mysql_files/caret-l.gif" alt="&lt;" width="11" height="7">mssql_select_db</a>
 </span>
 <hr>
 <span class="lastupdated">Last updated: Fri, 20 Mar 2009</span>
 <div class="langchooser">
  &nbsp;
 </div>
</div>
<!--/UdmComment-->


 </div>
 <div class="cleaner">&nbsp;</div>
</div>

<div id="footnav">
   <a href="http://au2.php.net/source.php?url=/manual/en/book.mysql.php">show source</a> |
 <a href="http://au2.php.net/credits.php">credits</a> |
 <a href="http://au2.php.net/sitemap.php">sitemap</a> |
 <a href="http://au2.php.net/contact.php">contact</a> |
 <a href="http://au2.php.net/contact.php#ads">advertising</a> |
 <a href="http://au2.php.net/mirrors.php">mirror sites</a>
</div>

<div id="pagefooter">
 <div id="copyright">
  <a href="http://au2.php.net/copyright.php">Copyright © 2001-2009 The PHP Group</a><br>
  All rights reserved.
 </div>

 <div id="thismirror">
  <a href="http://au2.php.net/mirror.php">This mirror</a> generously provided by:
  <a href="http://hosting.myob.com.au/">MYOB Business Web Hosting</a><br>
  Last updated: Sat Mar 21 14:41:29 2009 UTC
 </div>
</div>

</body></html>